package cn.itcast.service.packing.impl;

import cn.hutool.core.util.IdUtil;
import cn.itcast.dao.packing.ShippingOrderDao;
import cn.itcast.domain.packing.ShippingOrder;
import cn.itcast.domain.packing.ShippingOrderExample;
import cn.itcast.service.packing.ShippingOrderService;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
@Service
public class ShippingOrderServiceImpl implements ShippingOrderService {


    @Autowired
    ShippingOrderDao shippingOrderDao;

    @Override
    public List<ShippingOrder> findAll(ShippingOrderExample example) {
        return shippingOrderDao.selectByExample(example);
    }

    @Override
    public ShippingOrder findById(String id) {
        return shippingOrderDao.selectByPrimaryKey(id);
    }

    @Override
    public void save(ShippingOrder shippingOrder) {
        shippingOrder.setState(0);
        shippingOrderDao.insertSelective(shippingOrder);
    }

    @Override
    public void update(ShippingOrder shippingOrder) {
        shippingOrderDao.updateByPrimaryKeySelective(shippingOrder);
    }

    @Override
    public void delete(String id) {
        shippingOrderDao.deleteByPrimaryKey(id);
    }

    @Override
    public PageInfo findByPage(int pageNum, int pageSize, ShippingOrderExample example) {
        PageHelper.startPage(pageNum, pageSize);
        List<ShippingOrder> shippingOrderList = shippingOrderDao.selectByExample(example);
        return new PageInfo(shippingOrderList);
    }
}
